package com.bokee.archerwq.lab.mina.codec;

import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

public class TimeCodecFactory implements ProtocolCodecFactory {

	private final ProtocolEncoder encoder;
	private final ProtocolDecoder decoder;

	public TimeCodecFactory(boolean client) {
		if (client) {
			encoder = new RequestEncoder();
			decoder = new ResponseDecoder();
		} else {
			encoder = new ResponseEncoder();
			decoder = new RequestDecoder();
		}
	}

	@Override
	public ProtocolDecoder getDecoder() throws Exception {
		return decoder;
	}

	@Override
	public ProtocolEncoder getEncoder() throws Exception {
		return encoder;
	}

}
